//@author A0083338B

import java.util.LinkedList;

public class CommandHistory {
	LinkedList<String> inputStack;
	
	private AutoFill robot = null;
	public CommandHistory() {
		robot = new AutoFill();
		inputStack = new LinkedList<String>();
	}
	
	public void addInput(String cmd) {
		inputStack.add(cmd);
	}
	
	public void pop() {//previous command
		String cmd = inputStack.remove(inputStack.size() - 1);
		if(cmd == null) return;
		robot.input(cmd);
		inputStack.addFirst(cmd);
	}
	public void dpop() {//next command
		String cmd = inputStack.remove(0);
		if(cmd == null) return;
		robot.input(cmd);
		inputStack.addLast(cmd);
	}
	
}
